//
//  ByCellOrderDetailSecond.m
//  oc_knowledge
//
//  Created by mc on 17/1/20.
//  Copyright © 2017年 com.itboye. All rights reserved.
//

#import "ByCellOrderDetailSecond.h"
@implementation ByCellOrderDetailSecond
{
    //线
    UIView   *_lineView;
    UIView   *_lineView1;
    
    //按钮
    UIButton *_contactBtn;
    UIButton *_callBtn;

}
+ (instancetype)cellWithTableView:(UITableView*)tableView{
    
    static NSString *cellIdentifier = @"ByCellOrderDetailSecond";
    ByCellOrderDetailSecond *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
    if (cell == nil) {
        cell = [[self alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
    }
    return cell;
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSeparatorStyleNone;
        self.backgroundColor = [UIColor whiteColor];
        [self setViews];
    }
    return self;
}

-(void)setViews{
    _lineView = [[UIView alloc] init];
    _lineView.backgroundColor = [UIColor colorWithWhite:0.90 alpha:1];
    [self addSubview:_lineView];
    
    _lineView1 = [[UIView alloc] init];
    _lineView1.backgroundColor = [UIColor colorWithWhite:0.90 alpha:1];
    [self addSubview:_lineView1];
    
    _contactBtn = [[UIButton alloc] init];
    [self addSubview:_contactBtn];
    
    _callBtn = [[UIButton alloc] init];
    [self addSubview:_callBtn];

}

-(void)setModel:(ByModelOrderDetail *)model{
    _model = model;
    //动态创建支付信息cell
    CGFloat x,y,width,height;
    CGFloat maxWidth = 0;           //用来记录价格宽度
    height = 15;
    for (int i = 0; i < model.payInfoAry.count; i ++) {
        NSDictionary *dic = model.payInfoAry[i];
        width = [[dic allValues][0] getSizeOfString:14].width;
        maxWidth = maxWidth > width?maxWidth:width;
        x = SCREEN_WIDTH - 10 - maxWidth;
        y = 10*(i+1) + i*height;
        UILabel *pricelabel = [[UILabel alloc] initWithFrame:CGRectMake(x, y, width, height)];
        pricelabel.font = FONT(14);
        pricelabel.text = [dic allValues][0];
        if (i == model.payInfoAry.count -1) {
            pricelabel.textColor = [UIColor blackColor];
        }else{
            pricelabel.textColor = [UIColor lightGrayColor];

        }
        [self addSubview:pricelabel];
    }
    x = 10;
    UILabel *titleLabel;
    for (int i = 0; i < model.payInfoAry.count; i ++) {
        y = 10*(i + 1) + i *height;
        width = SCREEN_WIDTH - maxWidth - 30;
        titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(x, y, width, height)];
        titleLabel.font = FONT(14);
        NSDictionary *dic = model.payInfoAry[i];
        titleLabel.text = [dic allKeys][0];
        if (i == model.payInfoAry.count -1) {
            titleLabel.textColor = [UIColor blackColor];
        }else{
            titleLabel.textColor = [UIColor lightGrayColor];
        }
        titleLabel.tag = 10 + i;
        [self addSubview:titleLabel];
    }
    
    //线
    _lineView.frame = CGRectMake(0, titleLabel.bottom + 10, SCREEN_WIDTH, 0.5);
    
    //联系卖家跟拨打电话
    
    
    
    

}

@end
